﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Routing;

namespace ChoMy
{
    public class RouteConfig
    {
        public static void RegisterRoutes(RouteCollection routes)
        {
            routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

            routes.IgnoreRoute("{*botdetect}",
            new { botdetect = @"(.*)BotDetectCaptcha\.ashx" });

            // Events
            routes.MapRoute(
                name: "Events",
                url: "su-kien/{categoryNameId}",
                defaults: new
                {
                    controller = "Event",
                    action = "Index",
                    categoryNameId = UrlParameter.Optional
                },
                namespaces: new[] { "ChoMy.Controllers" }
            );

            // Event Details
            routes.MapRoute(
                name: "EventDetails",
                url: "su-kien/{categoryNameId}/{eventNameId}",
                defaults: new
                {
                    controller = "Event",
                    action = "Details",
                    categoryNameId = UrlParameter.Optional,
                    eventNameId = UrlParameter.Optional
                },
                namespaces: new[] { "ChoMy.Controllers" }
            );

            // Products
            routes.MapRoute(
               name: "Products",
               url: "san-pham/{categoryNameId}",
               defaults: new
               {
                   controller = "Product",
                   action = "Index",
                   categoryNameId = UrlParameter.Optional
               },
               namespaces: new[] { "ChoMy.Controllers" }
           );

            // Product Details
            routes.MapRoute(
               name: "ProductDetails",
               url: "san-pham/{categoryNameId}/{productNameId}",
               defaults: new
               {
                   controller = "Product",
                   action = "Details",
                   categoryNameId = UrlParameter.Optional,
                   productNameId = UrlParameter.Optional
               },
               namespaces: new[] { "ChoMy.Controllers" }
           );

            // Posts
            routes.MapRoute(
                name: "PostDetails",
                url: "bai-dang/{groupNameId}/{postNameId}",
                defaults: new
                {
                    controller = "Post",
                    action = "Details",
                    groupNameId = UrlParameter.Optional,
                    postNameId = UrlParameter.Optional
                },
                namespaces: new[] { "ChoMy.Controllers" }
            );

            // Search
            routes.MapRoute(
                name: "Search",
                url: "tim-kiem",
                defaults: new
                {
                    controller = "Product",
                    action = "Search"
                },
                namespaces: new[] { "ChoMy.Controllers" }
            );
           
            // Payment
            routes.MapRoute(
                name: "Payment",
                url: "thanh-toan/{receiverId}",
                defaults: new
                {
                    controller = "Payment",
                    action = "Index",
                    postNameId = UrlParameter.Optional
                },
                namespaces: new[] { "ChoMy.Controllers" }
            );

            routes.MapRoute(
                name: "Default",
                url: "{controller}/{action}/{id}",
                defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional },
                namespaces: new[] { "ChoMy.Controllers" }
            );
        }
    }
}
